package cn.edu.scau.cmi.yanghongyu.restcontroller;

import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.edu.scau.cmi.ema.controller.base.CmiEmaController;
import cn.edu.scau.cmi.front.service.FrontEchartService;
import cn.edu.scau.cmi.front.service.FrontEchartServiceImpl;
import cn.edu.scau.cmi.yanghongyu.dao.FrontSpiderEventDAO;
import cn.edu.scau.cmi.yanghongyu.dao.FrontEchartDAO;

@RestController("TestRestController")
public class TestRestController extends CmiEmaController {
	
	@Autowired
	FrontEchartService frontEchartService;
	
	@Autowired
	FrontEchartDAO frontEchartDAO;
	
	@Autowired	
	FrontSpiderEventDAO frontSpiderEventDAO;
	
	@RequestMapping("/fillupFoodtypeIdOfEchart")
	public String fillupFoodtypeIdOfEchart() {
		frontEchartService.fillupFoodtypeIdOfEchart();
//		Map<String, Integer> source = new HashMap<>();
//		Map<String, Integer> discovery = new HashMap<>();
//		Set<Address> set = addressDAO.findAddresssByParent(9, -1, -1);
//		for (Address address : set) {
//			source.put(address.getName(), cmiEventDAO.countEventByAddressName(address.getName(), "source"));
//			discovery.put(address.getName(), cmiEventDAO.countEventByAddressName(address.getName(), "discovery"));
//		}
//		
//		System.out.println(new Gson().toJson(source));
//		System.out.println(new Gson().toJson(discovery));
		
		return "OK";
	}

	@RequestMapping("/testGetOneTFWithoutMark")
	public Map<String, String> getOneTFWithoutMark() {
		return frontSpiderEventDAO.getSingleMarklessCrawlerEvent();
	}

}
